﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
    <title>开发者表单设计器</title>
    <!--引入jquery-->
    <script src="../../Scripts/jquery-1.11.0.min.js"></script>
    <!--引入bootstrap-->
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <script src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <!--引入ccpbm-->
    <link href="../../Style/skin/css/Default.css" rel="stylesheet" />
    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />

    <!--引入easyui-->
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js"></script>
    <script src="../../Scripts/EasyUIUtility.js"></script>
    <link href="../../Scripts/easyUI145/themes/default/easyui.css?v123" rel="stylesheet" />
    <link href="../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" />

    <!--引入CSS样式 begin-->
    <link href="css/default.css" rel="stylesheet" />
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" />

    <!--引入CSS样式 end-->
    <!--UEditer Begin-->
    <script src="js/ueditor/ueditor.config.js"></script>
    <script src="js/ueditor/ueditor.all.js"></script>
    <script src="js/ueditor/lang/zh-cn/zh-cn.js"></script>
    <!--<link href="js/ueditor/themes/iframe.css" rel="stylesheet" />-->
    <!--UEditer End-->
    <!--引入通用的JS-->
    <script src="../../Scripts/QueryString.js"></script>
    <script src="../../Scripts/config.js"></script>
    <script src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/PinYin.js"></script>
    <script src="Designer.js"></script>
    <script src="DesignerTools.js"></script>
    <script src="../../Comm/JS/Calendar/WdatePicker.js"></script>
    <link href="../../Comm/JS/Calendar/skin/WdatePicker.css" rel="stylesheet" />
    <style>
        body {
            background-color: #f7f6f9;
        }

        /*@media screen and (min-width: 1200px) {
            .cs-sidebar {
                width: 180px
            }
        }
        /* 设置了浏览器宽度不大于1200px时 abc 显示900px宽度 */

        /*@media screen and (max-width: 901px) {
            .cs-sidebar {
                width: 160px;
            }
        }
        /* 设置了浏览器宽度不大于901px时 abc 显示200px宽度 */

        /*@media screen and (max-width: 500px) {
            .cs-sidebar {
                width: 100px;
            }
        }*/
        #Btn_Save {
            background-image: url(../../Img/Btn/Save.png);
            background-repeat: no-repeat;
            background-size: 14px 14px;
            background-position: 0px 6px;
        }

        .cs-sidebar {
            padding-left: 8px;
            top: 46px;
            left: 14px;
            width: 180px;
            font-size: 13px;
            border: 0;
            background-color: #fff;
            box-shadow: 0 0 12px rgba(0,0,0,.1);
            border-radius: 4px;
        }

            .cs-sidebar .figurePanel {
                position: relative;
                padding: 10px 20px 10px 18px;
                background-color: #fff;
                border: 0;
            }

                .cs-sidebar .figurePanel img {
                    position: absolute;
                    right: 20px;
                    top: 50%;
                    transform: translateY(-50%);
                }

            .cs-sidebar .navlist li {
                background-color: #fff;
                cursor: pointer;
            }

                .cs-sidebar .navlist li:hover {
                    background-color: #e4eef8;
                }

                .cs-sidebar .navlist li div {
                    padding: 10px 0 10px 20px;
                    height: 38px;
                    width: 100%;
                    border: 0;
                    background-position: left 22px center;
                    background-size: 16px 16px;
                    box-sizing: border-box;
                }

        .cs-tree .content-wrapper {
            width: 90%;
            margin: 0px auto;
            box-shadow: 0 0 10px rgba(0,0,0,.1);
        }

        .cs-tree .tab-content {
            border: 0;
        }

        .cs-btn-group {
            padding: 8px 15px;
            background-color: #fff;
            border: 0;
            text-align: right;
            margin-bottom: 15px;
        }

            .cs-btn-group input[type="button"] {
                margin: 0 0 0 6px;
                padding: 0 14px;
                color: #fff;
                font-size: 13px;
                line-height: 14px;
                height: 26px;
                border: 0 none;
                border-radius: 3px;
                background-image: none;
                box-sizing: border-box;
            }

            .cs-btn-group span.l-btn-left.l-btn-left {
                padding: 0;
                background-image: none;
            }

        .SignCheck {
            border: thin solid #CCCCCC;
            width: 98%;
            height: 28px;
        }
    </style>
</head>
<body class="hold-transition skin-blue sidebar-mini cs-tree" style="overflow:hidden; position:fixed;width:100%">
    <div class="cs-btn-group">
        <button type="button" onclick="FrmAttr()" value="属性" class="cc-btn-tab btn-setting" id="Btn_FrmAttr">属性</button>
        <button type="button" onclick="SaveForm()" value="保存" class="cc-btn-tab btn-save" id="Btn_Save" name="Btn_Save" >保存</button>

        <!--<button type="button" onclick="FormatHtml()" value="格式化" class="cc-btn-tab btn-batch" id="Btn_View" />格式化</button>-->
        <!--<input type="button" onclick="SaveAs()" value="另存为" class="btn-light-yellow" id="Btn_SaveAs" />-->
        <button type="button" onclick="PreviewForm()" value="预览" class="cc-btn-tab btn-view" id="Btn_View">预览</button>
        <button type="button" onclick="leipiFormDesign.exec('impfrm')" class="cc-btn-tab btn-imp" value="导入" id="Btn_ImpTemplate" />导入</button>
        <button type="button" onclick="leipiFormDesign.exec('ImpFrmFields');" class="cc-btn-tab btn-delete" value="回收站" id="Btn_ImpFields" />回收站</button>
        <button type="button" onclick="leipiFormDesign.exec('FrmMobile');" class="cc-btn-tab btn-frmmobile" value="手机表单" id="Btn_FrmMobile" />手机</button>
        <button type="button" onclick="leipiFormDesign.exec('Template');" class="cc-btn-tab btn-template" value="插入模版" id="Btn_Template" />插入模版</button>
        <!--<button type="button" onclick="leipiFormDesign.exec('Style');" class="cc-btn-tab btn-style" value="样式编辑器" id="Btn_Template" />样式编辑器</button>-->
        <button type="button" onclick="OpenFoolFrm();" class="cc-btn-tab btn-foolfrm" value="傻瓜表单" id="Btn_FoolFrm" />傻瓜表单</button>
        <div id="msg"></div>
    </div>
    <!--左边导航-->
    <!--div class="main-sidebar cs-sidebar">
    <div class="sidebar">
        <div id="sidebar-menu" style="height:800px;">
            <div id="figures" style="height: 97%; overflow-y: auto; position: relative;">
                <div class="figurePanel">
                    <img src="../CCFormDesigner/Img/ico-menu-hide.png" align="middle" id="basicimg" />
                    <div>基本控件</div>
                </div>
                <div id="basic">
                    <ul class="navlist">
                        <li>
                            <div id="Button" style="background-image: url(../CCFormDesigner/Controls/basic/Button.png);" onclick="leipiFormDesign.exec('component','Btn');">
                                <span class="navlistspan">按钮</span>
                            </div>
                        </li>
                        <li>
                            <div id="HyperLink" style="background-image: url(../CCFormDesigner/Controls/basic/HyperLink.png);">
                                <span class="navlistspan">超链接</span>
                            </div>
                        </li>
                        <li>
                            <div id="HyperLink" style="background-image: url(../CCFormDesigner/Controls/basic/Img.png);" onclick="leipiFormDesign.exec('component','Img');">
                                <span class="navlistspan">图片</span>
                            </div>
                        </li>

                    </ul>
                </div>
                <div class="figurePanel">
                    <img src="../CCFormDesigner/Img/ico-menu-hide.png" align="middle" id="Dataimg" />
                    <div>字段控件</div>
                </div>
                <div id="Data">
                    <ul class="navlist">
                        <li>
                            <div id="TextBox" style="  background-image: url(../CCFormDesigner/Controls/Data/TextBox.png);" class="" onclick="leipiFormDesign.exec('text','Text');">
                                <span class="navlistspan">文本类型</span>
                            </div>
                        </li>
                        <li>
                            <div id="TextBox" style=" background-image: url(../CCFormDesigner/Controls/Data/TextBox.png);" class="" onclick="leipiFormDesign.exec('textarea');">
                                <span class="navlistspan">大文本类型</span>
                            </div>
                        </li>

                        <li>
                            <div id="TextBoxInt" style=" background-image: url(../CCFormDesigner/Controls/Data/TextBoxInt.png);" class="" onclick="leipiFormDesign.exec('text','Int');">
                                <span class="navlistspan">数值类型</span>
                            </div>
                        </li>
                        <li>
                            <div id="TextBoxMoney" style="background-image: url(../CCFormDesigner/Controls/Data/TextBoxMoney.png);" class="" onclick="leipiFormDesign.exec('text','Money');">
                                <span class="navlistspan">金额类型</span>
                            </div>
                        </li>
                        <li>
                            <div id="TextBoxFloat" style="background-image: url(../CCFormDesigner/Controls/Data/TextBoxFloat.png);" class="" onclick="leipiFormDesign.exec('text','Float');">
                                <span class="navlistspan">浮点类型</span>
                            </div>
                        </li>
                        <li>
                            <div id="Date" style="background-image: url(../CCFormDesigner/Controls/Data/TextBoxDate.png);" class="" onclick="leipiFormDesign.exec('text','Date');">
                                <span class="navlistspan">日期类型</span>
                            </div>
                        </li>
                        <li>
                            <div id="DateTime" style="background-image: url(../CCFormDesigner/Controls/Data/TextBoxDateTime.png);" class="" onclick="leipiFormDesign.exec('text','DateTime');">
                                <span class="navlistspan">日期时间类型</span>
                            </div>
                        </li>
                        <li>
                            <div id="CheckBox" style="background-image: url(../CCFormDesigner/Controls/Data/Checkbox.png);" class="" onclick="leipiFormDesign.exec('text','CheckBox');">
                                <span class="navlistspan">选择框</span>
                            </div>
                        </li>
                        <li>
                            <div id="RadioButton" style="background-image: url(../CCFormDesigner/Controls/Data/Radiobutton.png);" class="" onclick="leipiFormDesign.exec('enum','Radio');">
                                <span class="navlistspan">枚举单选按钮</span>
                            </div>
                        </li>
                        <li>
                            <div id="DropDownListEnum" style="background-image: url(../CCFormDesigner/Controls/Data/DropDownListEnum.png);" class="" onclick="leipiFormDesign.exec('enum','Select');">
                                <span class="navlistspan">枚举下拉框</span>
                            </div>
                        </li>
                        <li>
                            <div id="DropDownCheckEnum" style="background-image: url(../CCFormDesigner/Controls/Data/Checkbox.png);" class="" onclick="leipiFormDesign.exec('enum','CheckBox');">
                                <span class="navlistspan">枚举复选框</span>
                            </div>
                        </li>
                        <li>
                            <div id="DropDownListTable" class="" style="background-image: url(../CCFormDesigner/Controls/Data/DropDownListTable.png);" onclick="leipiFormDesign.exec('select');">
                                <span class="navlistspan">外键下拉框</span>
                            </div>
                        </li>
                    </ul>
                </div>
                <div class="figurePanel">
                    <img src="../CCFormDesigner/Img/ico-menu-hide.png" align="middle" id="Componentsimg" />
                    <div>组件类</div>
                </div>
                <div id="Components">
                    <ul class="navlist">
                        <li>
                            <div id="SignCheck" class="" style="background-image: url(../CCFormDesigner/Controls/ccbpm/FrmCheck.png);" onclick="leipiFormDesign.exec('text','SignCheck');">
                                <span class="navlistspan">签批组件</span>
                            </div>
                        </li>
                        <li>
                            <div id="FlowBBS" class="" style="background-image: url(../CCFormDesigner/Controls/ccbpm/FrmCheck.png);" onclick="leipiFormDesign.exec('text','FlowBBS');">
                                <span class="navlistspan">评论组件</span>
                            </div>
                        </li>

                        <li>
                            <div id="GovDocFile" class="" style="background-image: url(../CCFormDesigner/Controls/ccbpm/GovDocFile.png);" onclick="leipiFormDesign.exec('component','GovDocFile');">
                                <span class="navlistspan">公文正文组件</span>
                            </div>
                        </li>

                        <li>
                            <div id="DocWord" class="" style="background-image: url(../CCFormDesigner/Controls/ccbpm/FrmCheck.png);" onclick="leipiFormDesign.exec('component','DocWord');">
                                <span class="navlistspan">发文字号</span>
                            </div>
                        </li>

                        <li>
                            <div id="DocWordReceive" class="" style="background-image: url(../CCFormDesigner/Controls/ccbpm/FrmCheck.png);" onclick="leipiFormDesign.exec('component','DocWordReceive');">
                                <span class="navlistspan">收文字号</span>
                            </div>
                        </li>

                        <li>
                            <div id="Dtl" class="" style="background-image: url(../CCFormDesigner/Controls/Components/Dtl.png);" onclick="leipiFormDesign.exec('dtl');">
                                <span class="navlistspan">明细表/从表</span>
                            </div>
                        </li>
                        <li>
                            <div id="AthMulti" style="background-image: url(../CCFormDesigner/Controls/Components/AthMulti.png);" onclick="leipiFormDesign.exec('ath');">
                                <span class="navlistspan">多附件</span>
                            </div>
                        </li>

                        <li>
                            <div id="AthImg" style="background-image: url(../CCFormDesigner/Controls/Components/AthImg.png);" onclick="leipiFormDesign.exec('component','AthImg');">
                                <span class="navlistspan">图片附件</span>
                            </div>
                        </li>
                        <li>
                            <div id="HandSiganture" style="background-image: url(../CCFormDesigner/Controls/Components/HandSiganture.png);" onclick="leipiFormDesign.exec('component','HandWriting');">
                                <span class="navlistspan">签字板</span>
                            </div>
                        </li>
                        <li>
                            <div id="iFrame" style="background-image: url(../CCFormDesigner/Controls/Components/iFrame.png);" onclick="leipiFormDesign.exec('component','IFrame');">
                                <span class="navlistspan">框架</span>
                            </div>
                        </li>
                    </ul>
                </div>
                <div class="figurePanel">
                    <img src="../CCFormDesigner/Img/ico-menu-hide.png" align="middle" id="mobileimg" />
                    <div>控件</div>
                </div>
                <div id="mobile">
                    <ul class="navlist">
                        <li>
                            <div id="Map" style="background-image: url(../CCFormDesigner/Controls/mobile/Map.png);" onclick="leipiFormDesign.exec('component','Map');">
                                <span class="navlistspan">地图控件</span>
                            </div>
                        </li>
                        <li>
                            <div id="Map" style="background-image: url(../CCFormDesigner/Controls/mobile/Map.png);" onclick="leipiFormDesign.exec('component','Score');">
                                <span class="navlistspan">评分控件</span>
                            </div>
                        </li>
                        <--<li>
                            <div id="Camera" style="background-image: url(../CCFormDesigner/Controls/mobile/Camera.png);">
                                <span class="navlistspan">拍照上传</span>
                            </div>
                        </li>
                        <li>
                            <div id="SoundRecord" style="background-image: url(../CCFormDesigner/Controls/mobile/SoundRecord.png);">
                                <span class="navlistspan">录音</span>
                            </div>
                        </li>
                        <li>
                            <div id="VideoRecord" style="background-image: url(../CCFormDesigner/Controls/mobile/VideoRecord.png);">
                                <span class="navlistspan">录像</span>
                            </div>
                        </li>
                        <li>
                            <div id="QRCode" style="background-image: url(../CCFormDesigner/Controls/mobile/QRCode.png);">
                                <span class="navlistspan">二维码</span>
                            </div>
                        </li>->
                    </ul>
                </div>
                <div class="figurePanel">
                    <img src="../CCFormDesigner/Img/ico-menu-hide.png" align="middle" id="ccbpmimg" />
                    <div>流程组件</div>
                </div>
                <div id="ccbpm">
                    <ul class="navlist">
                        <li>
                            <div id="FlowChart" style="background-image: url(../CCFormDesigner/Controls/ccbpm/FlowChart.png);" onclick="leipiFormDesign.exec('component','JobSchedule');">
                                <span class="navlistspan">进度图</span>
                            </div>
                        </li>
                        <li>
                            <div id="FrmCheck" style="background-image: url(../CCFormDesigner/Controls/ccbpm/FrmCheck.png);" onclick="leipiFormDesign.exec('component','WorkCheck');">
                                <span class="navlistspan">审核组件</span>
                            </div>
                        </li>
                        <li>
                            <div id="SubFlowDtl" style="background-image: url(../CCFormDesigner/Controls/ccbpm/SubFlowDtl.png);" onclick="leipiFormDesign.exec('component','SubFlow');">
                                <span class="navlistspan">子流程</span>
                            </div>
                        </li>

                    </ul>
                </div>
            </div>
        </div>
    </div>
    </div-->
    <!--中间内容-->
    <div id="content-wrapper" class="content-wrapper">
        <div class="tab-content">
            <div class="row" style="height:auto">
                <script id="myFormDesign" type="text/plain" style="margin-left:20px;margin-right:20px;">
                </script>
            </div><!--end row-->
        </div>
        <!--<ul class="nav nav-tabs" id="myTab">
            <li class="active">
                <a data-toggle="tab" href="#designer">设计</a>
            </li>
            <li>
                <a data-toggle="tab" href="#html">Html</a>
            </li>

            <li>
                <a data-toggle="tab" href="#code">后台代码</a>
            </li>

        </ul>-->
    </div>
</body>
<script type="text/javascript">
    var leipiEditor = UE.getEditor('myFormDesign', {
        toolleipi: true,//是否显示，设计器的 toolbars
        textarea: 'design_content',
        //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
        toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline',
            'fontborder', 'strikethrough', 'removeformat',
            '|', 'forecolor', 'backcolor', 'insertorderedlist',
            'insertunorderedlist', '|', 'fontfamily', 'fontsize', '|', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
            'link', 'unlink', '|', 'simpleupload', 'horizontal', 'spechars',
            'wordimage', '|', 'inserttable', 'deletetable', 'mergecells',
            'splittocells'/*, '|', 'template'*/]],
        //focus时自动清空初始化时的内容
        //autoClearinitialContent:true,
        //关闭字数统计
        wordCount: false,
        //关闭elementPath
        elementPathEnabled: false,
        //默认的编辑区域高度
        initialFrameHeight: 300
        //更多其他参数，请参考ueditor.config.js中的配置项
    });

    //给富文本赋值
    window.onload = function () {
        var htmlContent = "";

        //数据库中查找
        var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_DevelopDesigner");
        handler.AddPara("FK_MapData", pageParam.fk_mapdata);
        htmlContent = handler.DoMethodReturnString("Designer_Init");

        leipiEditor.ready(function () {//编辑器初始化完成再赋值
            leipiEditor.setHeight(document.body.clientHeight - 160);
            leipiEditor.setContent(htmlContent, false);;  //赋值给UEditor
        });

        if (leipiEditor) {


            //调整样式,让必选的红色 * 随后垂直居中
            $(leipiEditor.container).css({ "display": "inline-block", "margin-right": "4px", "vertical-align": "middle" });
        }


    };
    var leipiFormDesign = {
        exec: function (method, dataType) {
            leipiEditor.execCommand(method, dataType);
        },
        /*
           Javascript 解析表单
           template 表单设计器里的Html内容
           fields 字段总数
       */
        parse_form: function (template, fields) {
            //正则  radios|checkboxs|select 匹配的边界 |--|  因为当使用 {} 时js报错
            var preg = /(\|-<span(((?!<span).)*leipiplugins=\"(radios|checkboxs|select)\".*?)>(.*?)<\/span>-\||<(img|input|textarea|select).*?(<\/select>|<\/textarea>|\/>))/gi, preg_attr = /(\w+)=\"(.?|.+?)\"/gi, preg_group = /<input.*?\/>/gi;
            if (!fields) fields = 0;

            var template_parse = template, template_data = new Array(), add_fields = new Object(), checkboxs = 0;

            var pno = 0;
            template.replace(preg, function (plugin, p1, p2, p3, p4, p5, p6) {
                var parse_attr = new Array(), attr_arr_all = new Object(), name = '', select_dot = '', is_new = false;
                var p0 = plugin;
                var tag = p6 ? p6 : p4;

                if (tag == 'radios' || tag == 'checkboxs') {
                    plugin = p2;
                } else if (tag == 'select') {
                    plugin = plugin.replace('|-', '');
                    plugin = plugin.replace('-|', '');
                }
                plugin.replace(preg_attr, function (str0, attr, val) {
                    if (attr == 'name') {
                        if (val == 'leipiNewField') {
                            is_new = true;
                            fields++;
                            val = 'data_' + fields;
                        }
                        name = val;
                    }

                    if (tag == 'select' && attr == 'value') {
                        if (!attr_arr_all[attr]) attr_arr_all[attr] = '';
                        attr_arr_all[attr] += select_dot + val;
                        select_dot = ',';
                    } else {
                        attr_arr_all[attr] = val;
                    }
                    var oField = new Object();
                    oField[attr] = val;
                    parse_attr.push(oField);
                })
                /*alert(JSON.stringify(parse_attr));return;*/
                if (tag == 'checkboxs') /*复选组  多个字段 */ {
                    plugin = p0;
                    plugin = plugin.replace('|-', '');
                    plugin = plugin.replace('-|', '');
                    var name = 'checkboxs_' + checkboxs;
                    attr_arr_all['parse_name'] = name;
                    attr_arr_all['name'] = '';
                    attr_arr_all['value'] = '';

                    attr_arr_all['content'] = '<span leipiplugins="checkboxs"  title="' + attr_arr_all['title'] + '">';
                    var dot_name = '', dot_value = '';
                    p5.replace(preg_group, function (parse_group) {
                        var is_new = false, option = new Object();
                        parse_group.replace(preg_attr, function (str0, k, val) {
                            if (k == 'name') {
                                if (val == 'leipiNewField') {
                                    is_new = true;
                                    fields++;
                                    val = 'data_' + fields;
                                }

                                attr_arr_all['name'] += dot_name + val;
                                dot_name = ',';

                            }
                            else if (k == 'value') {
                                attr_arr_all['value'] += dot_value + val;
                                dot_value = ',';

                            }
                            option[k] = val;
                        });

                        if (!attr_arr_all['options']) attr_arr_all['options'] = new Array();
                        attr_arr_all['options'].push(option);
                        //if(!option['checked']) option['checked'] = '';
                        var checked = option['checked'] != undefined ? 'checked="checked"' : '';
                        attr_arr_all['content'] += '<input type="checkbox" name="' + option['name'] + '" value="' + option['value'] + '"  ' + checked + '/>' + option['value'] + '&nbsp;';

                        if (is_new) {
                            var arr = new Object();
                            arr['name'] = option['name'];
                            arr['leipiplugins'] = attr_arr_all['leipiplugins'];
                            add_fields[option['name']] = arr;

                        }

                    });
                    attr_arr_all['content'] += '</span>';

                    //parse
                    template = template.replace(plugin, attr_arr_all['content']);
                    template_parse = template_parse.replace(plugin, '{' + name + '}');
                    template_parse = template_parse.replace('{|-', '');
                    template_parse = template_parse.replace('-|}', '');
                    template_data[pno] = attr_arr_all;
                    checkboxs++;

                } else if (name) {
                    if (tag == 'radios') /*单选组  一个字段*/ {
                        plugin = p0;
                        plugin = plugin.replace('|-', '');
                        plugin = plugin.replace('-|', '');
                        attr_arr_all['value'] = '';
                        attr_arr_all['content'] = '<span leipiplugins="radios" name="' + attr_arr_all['name'] + '" title="' + attr_arr_all['title'] + '">';
                        var dot = '';
                        p5.replace(preg_group, function (parse_group) {
                            var option = new Object();
                            parse_group.replace(preg_attr, function (str0, k, val) {
                                if (k == 'value') {
                                    attr_arr_all['value'] += dot + val;
                                    dot = ',';
                                }
                                option[k] = val;
                            });
                            option['name'] = attr_arr_all['name'];
                            if (!attr_arr_all['options']) attr_arr_all['options'] = new Array();
                            attr_arr_all['options'].push(option);
                            //if(!option['checked']) option['checked'] = '';
                            var checked = option['checked'] != undefined ? 'checked="checked"' : '';
                            attr_arr_all['content'] += '<input type="radio" name="' + attr_arr_all['name'] + '" value="' + option['value'] + '"  ' + checked + '/>' + option['value'] + '&nbsp;';

                        });
                        attr_arr_all['content'] += '</span>';

                    } else {
                        attr_arr_all['content'] = is_new ? plugin.replace(/leipiNewField/, name) : plugin;
                    }
                    template = template.replace(plugin, attr_arr_all['content']);
                    template_parse = template_parse.replace(plugin, '{' + name + '}');
                    template_parse = template_parse.replace('{|-', '');
                    template_parse = template_parse.replace('-|}', '');
                    if (is_new) {
                        var arr = new Object();
                        arr['name'] = name;
                        arr['leipiplugins'] = attr_arr_all['leipiplugins'];
                        add_fields[arr['name']] = arr;
                    }
                    template_data[pno] = attr_arr_all;


                }
                pno++;
            })
            var parse_form = new Object({
                'fields': fields,//总字段数
                'template': template,//完整html
                'parse': template_parse,//控件替换为{data_1}的html
                'data': template_data,//控件属性
                'add_fields': add_fields//新增控件
            });
            return JSON.stringify(parse_form);
        },
        fnCheckForm: function (type) {
            SaveForm();
        },

        fnReview: function () {
            if (leipiEditor.queryCommandState('source'))
                leipiEditor.execCommand('source');//切换到编辑模式才提交，否则有bug

            if (leipiEditor.hasContents()) {
                leipiEditor.sync();       //同步内容
                SaveForm();
                var url = "../../CCForm/Frm.htm?FrmID=" + pageParam.fk_mapdata + "&FK_MapData=" + pageParam.fk_mapdata;
                window.open(url);
            } else {
                alert('表单内容不能为空！');
                return false;
            }
        }
    };

</script>
</html>
